//
//  DriverVehicleManagementCell.m
//  NtoccDriverNew
//
//  Created by wanxiang liu on 2021/9/22.
//  Copyright © 2021 GCY. All rights reserved.
//

#import "DriverVehicleManagementCell.h"

@interface DriverVehicleManagementCell ()
@property (weak, nonatomic) IBOutlet UILabel *plateLabel;
@property (weak, nonatomic) IBOutlet UILabel *defaultLabel;
@property (weak, nonatomic) IBOutlet UILabel *reviewStatusLabel;
@property (weak, nonatomic) IBOutlet UILabel *loadLabel;
@property (weak, nonatomic) IBOutlet UIButton *defaultButton;
@property (weak, nonatomic) IBOutlet UIButton *editButton;
@property (weak, nonatomic) IBOutlet UILabel *resionL;

@property (weak, nonatomic) IBOutlet UIStackView *stackView;

- (IBAction)defaultButtonClick;
- (IBAction)editButtonClick;
- (IBAction)deleteButtonClick;

@end

@implementation DriverVehicleManagementCell

- (void)setModel:(DriverVehicleModel *)model {
//    _deleteButtonA.hidden = YES;
    _model = model;
    
    _reviewStatusLabel.layer.cornerRadius = 5;
    _reviewStatusLabel.layer.masksToBounds = YES;
    
    _defaultLabel.layer.cornerRadius = 5;
    _defaultLabel.layer.masksToBounds = YES;
    
    self.plateLabel.text = StringCheck(model.licenseNumber);
    
    self.resionL.text = @"";
    switch (model.authStatusExt) {
        case 0: {
            self.reviewStatusLabel.text = @"未审核";
            self.reviewStatusLabel.textColor = UIColor.whiteColor;
            self.reviewStatusLabel.backgroundColor = [UIColor colorWithHexString:@"#FED864"];
        }
            break;
        case 1: {
            self.reviewStatusLabel.text = @"审核中";
            self.reviewStatusLabel.textColor = UIColor.whiteColor;
            self.reviewStatusLabel.backgroundColor = [UIColor colorWithHexString:@"#FED864"];
        }
            break;
        case 2: {
            self.reviewStatusLabel.text = @"审核驳回";
            self.reviewStatusLabel.textColor = UIColor.whiteColor;
            self.reviewStatusLabel.backgroundColor = [UIColor colorWithHexString:@"#FF3D1D"];
            self.resionL.text = [@"驳回原因:" stringByAppendingString:model.authMsg];
        }
            break;
        case 3: {
            self.reviewStatusLabel.text = @"审核通过";
            self.reviewStatusLabel.textColor = UIColor.whiteColor;
            self.reviewStatusLabel.backgroundColor = [UIColor colorWithHexString:@"#006FFF"];
        }
            break;
            
        default:
            break;
    }
    
    self.loadLabel.text = model.loadStatus == DriverVehicleLoadStatus_KongZai ? @"空载" : @"负载";

    self.defaultLabel.hidden = ![model.vehicleCode isNotBlank] ? YES : NO;
    self.defaultButton.hidden = [model.vehicleCode isNotBlank] ? YES : NO;
    
    [self.editButton setTitle:[model.teamCode isEqualToString:[UserDefaultUtil valueForKey:DriverPartyCode]] ? @"编辑" : @"查看" forState:UIControlStateNormal];
    self.editButton.hidden = YES;
}

- (IBAction)deleteButtonClick {
    if ([self.delegate respondsToSelector:@selector(cellClickDeleteWithModel:)]) {
        [self.delegate cellClickDeleteWithModel:self.model];
    }
}

- (IBAction)editButtonClick {
    if ([self.delegate respondsToSelector:@selector(cellClickEditWithModel:)]) {
        [self.delegate cellClickEditWithModel:self.model];
    }
}

- (IBAction)defaultButtonClick {
    if ([self.delegate respondsToSelector:@selector(cellClickDefaultWithModel:)]) {
        [self.delegate cellClickDefaultWithModel:self.model];
    }
}
@end
